import request from '../req'
import type { PageInfoDto, PageQueryDto } from '../commonType'
import type { MemberCardDto, RightsDto, RightsDataDto, MemberShipCheckedDto, QueryVipCompanyDto, VipCompanyDto, AddVipCardReqDto } from './type'
/**
 * @description 获取会员卡列表
 * @returns 
 */
export const getCardList = async (): Promise<MemberCardDto[]> => {
    return request.get('/saas/vip/card/settings/query-list')
}

/**
 * @description 获取会员卡权益列表
 * @param data 
 * @returns 
 */
export const getRightsList = async (data: { id: number } & PageQueryDto): Promise<PageInfoDto<RightsDto>> => {
    return request.get('/saas/vip/card/settings/query-rights-list', {
        params: data
    })
}

/**
 * @description 获取权益相关数据
 * @param data 
 * @returns 
 */
export const getRightsData = async (data: { id: number, rightsType: number }): Promise<RightsDataDto> => {
    return request.get('/saas/vip/card/settings/query-rights-data', {
        params: data,
        noLoading: true
    })
}

/**
 * @description 获取核销记录列表
 * @param data 
 * @returns 
 */
/**
 * 获取已勾选的列表
 *
 * @param data 包含排序字段和排序顺序的查询参数对象，以及分页查询参数对象
 * @returns 返回一个包含分页信息和已勾选列表的 Promise 对象
 */
export const getCheckedList = async (data: { sortField?: string, sortOrder?: string } & PageQueryDto): Promise<PageInfoDto<MemberShipCheckedDto>> => {
    return request.get('/saas/vip/card/rights/use/record/query-record-list', {
        params: data
    })
}

/**
 * @description获取 VIP 列表
 * @param data 查询 VIP 列表所需的数据，包括分页和筛选条件
 * @returns 返回 VIP 列表的分页信息
 */
export const getVipList = async (data: Partial<QueryVipCompanyDto & PageQueryDto>): Promise<PageInfoDto<VipCompanyDto>> => {
    return request.get('/saas/vip/card/company/query-vip-company-list', {
        params: data
    })
}

export const setVipCard = async (data: AddVipCardReqDto): Promise<string> => {
    return request.post('/saas/vip/card/settings/vip-card-setting', data)
}
